#include <iostream>

using namespace std;

const int N = 1e4 + 10;

int f[N];
int x[N], y[N], t[N];
int n, m;

int main()
{
	cin >> n >> m;
	int ret = 0;
	for(int i = 1; i <= m; i++)
	{
		f[i] = 1;
		cin >> t[i] >> x[i] >> y[i];
		for(int j = 1; j < i; j++)
		{
			if(t[i] - t[j] >= abs(x[i] - x[j]) + abs(y[i] - y[j]))
			{
				f[i] = max(f[i], f[j] + 1);
			}
		}
		ret = max(ret, f[i]);
	} 
	cout << ret << endl;
	return 0;
}
